#ifdef RUN_TEST

#include "AlgoTest.h"
//#include "stdio.h"
#include "../../types.h"

#include "../../algorithm.h"

// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( AlgoTest );


/**
 *	two equal blocks in one file
 */
void AlgoTest::Test1()
{
	//	Prepare inc data
	IncomingData incData;
	FileData file1;
	for (uint i = 0; i < 6; ++i)
		file1.push_back(i);
	for (uint i = 0; i < 6; ++i)
		file1.push_back(i);
	incData.push_back(file1);
	//Algo::PrintIncData(incData);

	ResultData resData;
	Algo::FindEqualBlocks(incData, resData);

	ResultData testResData;
	Block block1(0, 0);
	Block block2(0, 6);
	EqualBlocks eqBlocks;
	eqBlocks.push_back(block1);
	eqBlocks.push_back(block2);
	GroupOfBlocks group;
	group.push_back(eqBlocks);
	testResData.insert(std::make_pair(6, group));

	CPPUNIT_ASSERT(resData == testResData);
}

/**
 *	two equal blocks in two file
 */
void AlgoTest::Test2()
{
	//	Prepare inc data
	IncomingData incData;
	FileData file1;
	for (uint i = 0; i < 6; ++i)
		file1.push_back(i);
	FileData file2;
	for (uint i = 0; i < 6; ++i)
		file2.push_back(i);
	incData.push_back(file1);
	incData.push_back(file2);
	//Algo::PrintIncData(incData);

	ResultData resData;
	Algo::FindEqualBlocks(incData, resData);

	ResultData testResData;
	Block block1(0, 0);
	Block block2(1, 0);
	EqualBlocks eqBlocks;
	eqBlocks.push_back(block1);
	eqBlocks.push_back(block2);
	GroupOfBlocks group;
	group.push_back(eqBlocks);
	testResData.insert(std::make_pair(6, group));

	CPPUNIT_ASSERT(resData == testResData);
}

/**
 *	two equal blocks in one file + one in second file
 */
void AlgoTest::Test3()
{
	//	Prepare inc data
	IncomingData incData;
	FileData file1;
	for (uint i = 0; i < 6; ++i)
		file1.push_back(i);
	file1.push_back(10);
	for (uint i = 0; i < 6; ++i)
		file1.push_back(i);
	FileData file2;
	for (uint i = 0; i < 6; ++i)
		file2.push_back(i);
	incData.push_back(file1);
	incData.push_back(file2);
	//Algo::PrintIncData(incData);

	ResultData resData;
	Algo::FindEqualBlocks(incData, resData);

	ResultData testResData;
	Block block1(0, 0);
	Block block2(0, 7);
	Block block3(1, 0);
	EqualBlocks eqBlocks;
	eqBlocks.push_back(block1);
	eqBlocks.push_back(block2);
	eqBlocks.push_back(block3);
	GroupOfBlocks group;
	group.push_back(eqBlocks);
	testResData.insert(std::make_pair(6, group));

	CPPUNIT_ASSERT(resData == testResData);
}

#endif	//	RUN_TEST